package task

import (
	"github.com/spf13/viper"
	"os"
)

type Config struct {
	AppName   string `mapstructure:"AppName"`
	Env       string `mapstructure:"Env"`
	Scheduler []Task `mapstructure:"Scheduler"`
}

//type Scheduler struct {
//	Spec    string `mapstructure:"Spec"`
//	Commend string `mapstructure:"Commend"`
//	Open    bool   `mapstructure:"Open"`
//}

var config Config

func init() {
	home, err := os.UserHomeDir()
	viper.SetConfigName("config")
	viper.SetConfigType("yaml")
	viper.AddConfigPath(home)
	viper.AutomaticEnv()
	err = viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	viper.Unmarshal(&config)

}
